﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page, ICallbackEventHandler
{
     private static Hashtable hashTable;  
     protected String returnValue;
     protected void Page_Load(object sender, EventArgs e)
     {
         if (!IsPostBack)
         {
             String cbReference =
                 Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context");
             String callbackScript;
             callbackScript = "function CallServer(arg, context)" +
                 "{ " + cbReference + ";}";
             Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
                 "CallServer", callbackScript, true);

             hashTable = new Hashtable();
             hashTable.Add("Hawaii", "GMT -10:00");
             hashTable.Add("Central America", "GMT -06:00");
             hashTable.Add("Greenland", "GMT -03:00");
             hashTable.Add("Athens", "GMT +02:00");
             hashTable.Add("HaNoi", "GMT +07:00");

             DropDownList1.DataSource = hashTable;
             DropDownList1.DataTextField = "key"; //If you say value Values from HashTable will be added to Drpdownlist  
             DropDownList1.DataBind();
         }

     } 
    

    #region ICallbackEventHandler Members

    string ICallbackEventHandler.GetCallbackResult()
    {
        return returnValue;
    }

    void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
    {
        if (hashTable[eventArgument] == null)
        {
            returnValue = "-1";
        }
        else
        {
            returnValue = hashTable[eventArgument].ToString();
        }  
    }

    #endregion
}
